#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from store.mdb_store import TableStore


class CyzoneProjectListStore(TableStore):
    def __init__(self, config):
        self.table = config.get('table', 'cyzone_project_list')
        self.table_config = {
            'mdb': config['mdb'],
            'table': self.table,
            'column_dic': {
                'project_id': "INT NOT NULL DEFAULT '0' COMMENT '项目ID'",
                'name': "varchar(255) NOT NULL DEFAULT '' COMMENT '项目名称'",
                'stage': "varchar(50) NOT NULL DEFAULT '' COMMENT '融资轮次'",
                'found_time': "varchar(50) NOT NULL DEFAULT '' COMMENT '成立时间'",
                'tags': "text NOT NULL COMMENT '创业领域'",
                'desc': "text NOT NULL COMMENT '描述	'",
                'link': "text NOT NULL COMMENT '详情链接'",
                'logo': "text NOT NULL COMMENT 'icon'",
            },
            'uniq_idx_fields': ['project_id'],
            'idx_dic': {
                '{0}_name_idx'.format(self.table): ['name']
            },
            'text_fields': [
                'tags', 'desc', 'link', 'logo'
            ]
        }
        super(CyzoneProjectListStore, self).__init__(self.table_config)


class CyzoneProjectStore(TableStore):
    def __init__(self, config):
        self.table = config.get('table', 'cyzone_project')
        self.table_config = {
            'mdb': config['mdb'],
            'table': self.table,
            'column_dic': {
                'project_id': "INT NOT NULL DEFAULT '0' COMMENT '项目ID'",
                'name': "varchar(255) NOT NULL DEFAULT '' COMMENT '项目名称'",
                'company_name': "varchar(255) NOT NULL DEFAULT '' COMMENT '公司名称'",
                'company_scale': "varchar(255) NOT NULL DEFAULT '' COMMENT '公司规模'",
                'found_time': "varchar(50) NOT NULL DEFAULT '' COMMENT '成立时间'",
                'location': "varchar(50) NOT NULL DEFAULT '' COMMENT '地区'",
                'category': "varchar(50) NOT NULL DEFAULT '' COMMENT '分类'",
                'stage': "varchar(50) NOT NULL DEFAULT '' COMMENT '融资轮次'",
                'telephone': "varchar(255) NOT NULL DEFAULT '' COMMENT '电话'",
                'address': "varchar(255) NOT NULL DEFAULT '' COMMENT '公司地址'",
                'domain': "varchar(255) NOT NULL DEFAULT '' COMMENT '公司官网'",
                'email': "varchar(50) NOT NULL DEFAULT '' COMMENT '公司邮箱'",
                'slogan': "varchar(255) NOT NULL DEFAULT '' COMMENT '短语'",
                'tags': "text NOT NULL COMMENT '标签'",
                'desc': "text NOT NULL COMMENT '描述	'",
                'logo': "text NOT NULL COMMENT 'icon'",
                'business': "text NOT NULL COMMENT '合作伙伴'",
                'rounds': "text NOT NULL COMMENT '融资历史'",
                'competitor': "text NOT NULL COMMENT '竞品'",
                'news': "text NOT NULL COMMENT '新闻'",
                'videos': "text NOT NULL COMMENT '视频'",
            },
            'uniq_idx_fields': ['project_id'],
            'idx_dic': {
                '{0}_name_idx'.format(self.table): ['name']
            },
            'update_fields': [
                'company_scale', 'stage', 'telephone', 'domain', 'email', 'slogan',
                'tags', 'desc', 'logo', 'business', 'rounds', 'competitor', 'news',
                'videos'
            ],
            'text_fields': [
                'tags', 'desc', 'logo', 'business', 'rounds', 'competitor', 'news', 'videos'
            ],
            'dump_fields': [
                'business', 'rounds', 'competitor', 'news', 'videos'
            ]
        }
        super(CyzoneProjectStore, self).__init__(self.table_config)
